﻿using FingerTip.Domain.Sites.Rules;
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;

namespace FingerTip.Domain
{
    public class BasicSiteValidator<T>:AbstractValidator<T> where T:BasicSiteCommand
    {
        private readonly ISiteRules siteRules;
        public BasicSiteValidator(ISiteRules siteRules)
        {
            this.siteRules = siteRules;

            RuleFor(c => c.SiteId)
                .NotEmpty().WithMessage("Site id is required.")
                .Must(BeAnExistingSite).WithMessage("Site does not exits.");
        }

        private bool BeAnExistingSite(Guid siteId)
        {
            return siteRules.DoesSiteExist(siteId);
        }


    }
}
